/*
 * Assignment1.cpp
 *
 * Example code for Assignment #1
 *
 *  Created on: Feb 11, 2014
 *      Author: Anthony Varghese
 */

/*
 * Simple enumeration type -- see SingleSequence struct for example of use
 *
 */
enum sequenceType { dna, rna, protein };

#include <string>

/*
 * This SingleSequence struct is an example of how structs are used
 * - data members are public
 * - no methods
 * - different types for data members
 */
struct SingleSequence{
	std::string name;
	std::string seq;
	int length;
	double gccontent;
	sequenceType type;
};

/*
 * Sequences class is very different from structs
 *
 * A Sequences object will have an array of SingleSequence objects
 *
 */
class Sequences{
public:
	/*
	 * Constructor
	 */
	Sequences(){
		data[0] = { "KCNH2 Primer Pair 1 Forward", "CCAACTGGTGGACCGTCATT", 20, 55.0, dna };
		data[1] = { "KCNH2 Primer Pair 1 Reverse", "GACAGCCAGGTGAACATCCA", 20, 55.0, dna };
		data[2] = { "KCNH2 Primer Pair 2 Forward", "TGGATGTTCACCTGGCTGTC", 20, 55.0, dna };
		data[3] = { "KCNH2 Primer Pair 2 Reverse", "CCACGGAACCTCTGGCAATA", 20, 55.0, dna };
		data[4] = { "KCNH2 Primer Pair 3 Forward", "GAACGGAAGTGTGCCAACTG", 20, 55.0, dna };
		data[5] = { "KCNH2 Primer Pair 3 Reverse", "ACAGCCAGGTGAACATCCAG", 20, 55.0, dna };
		data[6] = { "KCNH2 Primer Pair 4 Forward", "CTGGATGTTCACCTGGCTGT", 20, 55.0, dna };
		data[7] = { "KCNH2 Primer Pair 4 Reverse", "ATTTCCACGGAACCTCTGGC", 20, 55.0, dna };
		data[8] = { "KCNH2 Primer Pair 5 Forward", "TGAAAACCGCTCGTCTGC", 18, 55.6, dna };
		data[9] = { "KCNH2 Primer Pair 5 Reverse", "GGTGGAGCATGTGTTGTT", 18, 50.0, dna };

		datasize = 10;
	}
	/*
	 * get method for datasize data member
	 */
	int getListSize() const {
		return datasize;
	}

	/*
	 * This get method returns a reference
	 */
	const SingleSequence& get(int i) const {
		if (i>=0 && i < datasize)
			return data[i];
		throw OUT_OF_BOUNDS; // C++ has exceptions - you can even throw ints
	}

	/*
	 * See if you can set up this sort method
	 */
	void sortByName(){

	}
	/*
	 * See if you can set up this sort method
	 */
	void sortByLength(){

	}

private:
	/*
	 * Remember to keep all data members private
	 */
	static const int MAX_LIST_SIZE = 20;
	SingleSequence data[MAX_LIST_SIZE];
	int datasize;
	static const int OUT_OF_BOUNDS = -1;
};

/*
 * The following two "functions" are for the Insertion operator "<<"
 * In C++ you can overload and redefine operators!
 *
 * The following operators are used from main - try stepping through main
 * in the debugger to see how the insertion operators are used!!
 */
#include <iostream>
std::ostream& operator<<(std::ostream& os, const SingleSequence& s){
	os << s.name << " " << s.seq << " " << s.length << " " << s.type;
	return os;
}
std::ostream& operator<<(std::ostream& os, const Sequences& seqs){
	os << "  Sequences object " << std::endl;
	for (int i=0; i < seqs.getListSize(); i++ )
		os << "    " << (i+1) <<":  " << seqs.get( i ) << std::endl;
	return os;
}

using namespace std;


int main(){
	cout << "Assignment #1" << endl;

	Sequences mysequences;
	cout << mysequences;
	cout << "Sorted by name" << endl;
	mysequences.sortByName();
	cout << mysequences;
	cout << "Sorted by length" << endl;
	mysequences.sortByLength();
	cout << mysequences;

	cout << "... done!" << endl;
}
